function en = tot_energy(N, state, K, alpha)

    en = 0.5 * K * (state{1}(1)^2 + state{N}(1)^2) + 1/3 * alpha * (state{1}(1)^3 - state{N}(1)^3) + 0.5 * state{N}(2)^2;
    
    for i =1:(N-1)
        eni = 0.5 * state{i}(2)^2 + 0.5 * K * (state{i}(1) - state{i+1}(1))^2 + 1/3 * alpha * (state{i+1}(1) - state{i}(1))^3;
        en = en + eni;
    end

    return
end